<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        /* var arr = ['小黑','小包','小白'];
        var val = arr.every(function (ele) {
            return ele.length = 2 ;
        })
        console.log(val); */

        function compare(a, b) {
            if (a < b ) {           // 按某种排序标准进行比较, a 小于 b
                return -1;
            }
            if (a > b ) {
                return 1;
            }
            // a must be equal to b
            return 0;
        }
        var arr = [10,20,30,90,80,60];
        arr.sort(compare);
        console.log(arr);
    </script>
</body>
</html>